function t(t) {
    if (Array.isArray(t)) {
        for (var a = 0, e = Array(t.length); a < t.length; a++) e[a] = t[a];
        return e;
    }
    return Array.from(t);
}

Page({
    data: {
        more_list: !1,
        _num: 1,
        share: 0,
        mch: 0,
        list: [],
        toSearch: !1,
        pass: !1,
        keyword: "",
        page: 2,
        noPass: !1,
        id: null,
        page_loading: !0,
        actions: [ {
            name: "取消",
            color: "#666666"
        }, {
            name: "确认",
            color: "#446dfd",
            loading: !1
        } ]
    },
    tab: function(t) {
        var a = t.currentTarget.dataset.num;
        this.setData({
            _num: a,
            list: [],
            keyword: ""
        }), this.getList(1);
    },
    onLoad: function(t) {
        getApp().page.onLoad(this,t)
        this.setData({
            share: t.share,
            mch: 1
        }), 0 == t.mch && 1 == t.share ? (wx.setNavigationBarTitle({
            title: "分销商审核消息"
        }), this.setData({
            _num: 2
        })) : 1 == t.mch && 0 == t.share && wx.setNavigationBarTitle({
            title: "入驻商审核消息"
        }); //this.getStatus();
    },
    beSearch: function() {
        var t = !this.data.toSearch;
        this.data.keyword.length > 0 && (t = this.data.toSearch), this.setData({
            toSearch: t
        });
    },
    input: function(t) {
        this.setData({
            keyword: t.detail.value
        });
    },
    search: function() {
        this.getList(1);
    },
    handleClick: function(a) {
        var e = a.detail;
        this.setData({
            status: 1
        });
        var i = e.index;
        0 === i ? this.setData({
            pass: !this.data.pass
        }) : 1 === i && ([].concat(t(this.data.actions))[1].loading = !0, this.submit());
    },
    handleClose: function(a) {
        var e = a.detail;
        this.setData({
            status: 2
        });
        var i = e.index;
        0 === i ? this.setData({
            noPass: !this.data.noPass
        }) : 1 === i && ([].concat(t(this.data.actions))[1].loading = !0, this.submit());
    },
    toPass: function(t) {
        var a = null;
        t.currentTarget.dataset.id > 0 && (a = t.currentTarget.dataset.id), this.setData({
            pass: !this.data.pass,
            id: a
        });
    },
    toNopass: function(t) {
        var a = null;
        t.currentTarget.dataset.id > 0 && (a = t.currentTarget.dataset.id), this.setData({
            noPass: !this.data.noPass,
            id: a
        });
    },
    submit: function() {
        var a = this;
        getApp().iView.$Toast({
            type: "loading",
            duration: 0
        }), getApp().request({
            url: getApp().apiUrl.app_admin.review_switch,
            data: {
                user_id: a.data.id,
                type: 2,
                status: a.data.status
            },
            method: "post"
        }).then(function(e) {
            getApp().iView.$Toast.hide(), 0 == e.data.code ? (getApp().iView.$Toast({
                content: e.data.msg,
                duration: 2,
                type: "success",
                mask: !1
            }), [].concat(t(a.data.actions))[1].loading = !1, a.setData({
                pass: !1,
                noPass: !1
            }), a.getList(1)) : getApp().iView.$Toast({
                content: e.data.msg,
                duration: 2,
                type: "warning"
            });
        }).catch(function(t) {
            getApp().iView.$Toast({
                content: t.data.msg,
                duration: 2,
                type: "error"
            });
        });
    },
    getStatus: function() {
        getApp().request({
            url: getApp().apiUrl.app_admin.tabs,
            method: "get"
        }).then(function(t) {
            getApp().iView.$Toast.hide(), 0 == t.data.code || getApp().iView.$Toast({
                content: t.data.msg,
                duration: 2,
                type: "warning"
            });
        }).catch(function(t) {
            getApp().iView.$Toast({
                content: t.data.msg,
                duration: 2,
                type: "error"
            });
        });
    },
    getList: function(t) {
        var a = this;
        wx.showLoading({
            content: "加载中"
        }), getApp().request({
            url: getApp().api.admin.mch.review,
            data: {
                page: t,
                type: this.data._num,
                keyword: this.data.keyword
            },
            method: "get",
            success: function(t) {
              wx.hideLoading()
              if (0 == t.code) {
                var e = t.data.list, i = !1;
                20 == e.length && 1 == a.data._num && (i = !0), 10 == e.length && 2 == a.data._num && (i = !0),
                  a.setData({
                    list: e,
                    more_list: i,
                    page: 2
                  });
              } else wx.showToast({
                title: t.msg,
                icon: 'none'
              });
            },
            fail: function (t) {
              wx.hideLoadging()
              wx.showToast({
                title: t.data.msg,
                icon: 'none'
              });
            }
        });
    },
    getMore: function(t) {
        var a = this;
        wx.showLoading({
            content: "加载中",
            type: "loading",
            duration: 0
        }), getApp().request({
            url: getApp().api.admin.mch.review,
            data: {
                page: t,
                type: this.data._num,
                keyword: this.data.keyword
            },
            method: "get",
            success: function (e) {
              wx.hideLoading()
              if (0 == e.code) {
                var i = a.data.list, n = e.data.list, s = !1;
                20 == n.length && 1 == a.data._num && (s = !0), 10 == n.length && 2 == a.data._num && (s = !0),
                  i = i.concat(n), t++ , a.setData({
                    list: i,
                    page: t,
                    more_list: s
                  });
              } else wx.showToast({
                title: e.data.msg,
                icon: 'none'
              });
            },
            fail: function (t) {
              wx.hideLoadging()
              wx.showToast({
                title: t.msg,
                icon: 'none'
              });
            }
        });
    },
    onReady: function(t) {
        this.setData({
            page_loading: !1
        });
    },
    onShow: function() {
        this.getList(1);
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.more_list && this.getMore(this.data.page);
    },
    onShareAppMessage: function() {}
});